from fastapi_amis_admin import amis, admin
from fastapi_amis_admin.admin import AdminApp

from .models import SysUser


class UserApp(admin.AdminApp):
    page_schema = amis.PageSchema(label='User', icon='fa fa-bolt')
    router_prefix = '/user'

    def __init__(self, app: "AdminApp"):
        super().__init__(app)
        self.register_admin(UserAdmin)


# Register your models here.

class UserAdmin(admin.ModelAdmin):
    page_schema = amis.PageSchema(label='User', icon='fa fa-folder')
    model = SysUser
    search_fields = [SysUser.username]
